package com.learn.jdk.caseDemo;

import java.util.function.Consumer;

/**
 * Copyright: Copyright (c) 2020 Asiainfo
 *
 * @ClassName: com.learn.jdk.caseDemo.LambdaUtils
 * @Description: 该类的功能描述
 * @version: v1.0.0
 * @author: lipan
 * @date: 2020/5/20 17:25
 * <p>
 * Modification History:
 * Date         Author          Version            Description
 * ------------------------------------------------------------
 * 2020/5/20      lipan          v1.0.0               修改原因
 */

public class LambdaUtils {


  public static   <T> Consumer <T> WrapperConsumer(MyConsumer <T> consumer){
      return t->{
         try {
             consumer.accept(t);
         } catch (Exception e) {
//             e.printStackTrace();
//             throw  new  RuntimeException(e);
             throwAsUnchecked(e);
         }

     };
   }


    @SuppressWarnings("unchecked")
    public static <E extends Throwable> void throwAsUnchecked(Exception exception) throws E {
        throw (E) exception;
    }
}
